Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Collections.​Generic.​EqualityComparer<​T>

Assembly: System.Collections

Inheritance: object → EqualityComparer

Implemented Interfaces

Provides a base class for implementations of the <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> generic interface.

Properties

public static EqualityComparer<​T>
Default
Returns a default equality comparer for the type specified by the generic argument.

Methods

public static EqualityComparer<​T>
Create​(Func<​T, T, bool> equals, Func?<​T, int> getHashCode = null)
Creates an <see cref="T:System.Collections.Generic.EqualityComparer`1" /> by using the specified delegates as the implementation of the comparer's <see cref="M:System.Collections.Generic.EqualityComparer`1.Equals(`0,`0)" /> and <see cref="M:System.Collections.Generic.EqualityComparer`1.GetHashCode(`0)" /> methods.
Returns The new comparer.
equals The delegate to use to implement the <see cref="M:System.Collections.Generic.EqualityComparer`1.Equals(`0,`0)" /> method.
getHashCode The delegate to use to implement the <see cref="M:System.Collections.Generic.EqualityComparer`1.GetHashCode(`0)" /> method. If no delegate is supplied, calls to the resulting comparer's <see cref="M:System.Collections.Generic.EqualityComparer`1.GetHashCode(`0)" /> will throw <see cref="T:System.NotSupportedException" /> .
public bool
Equals​(T x, T y)
When overridden in a derived class, determines whether two objects of type <typeparamref name="T" /> are equal.
Returns <see langword="true" /> if the specified objects are equal; otherwise, <see langword="false" /> .
x The first object to compare.
y The second object to compare.
public int
GetHashCode​(T obj)
When overridden in a derived class, serves as a hash function for the specified object for hashing algorithms and data structures, such as a hash table.
Returns A hash code for the specified object.
obj The object for which to get a hash code.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object